import os
import sys

from common.time_bdp import time_bdp
from core.rest_client import RestClient
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(BASE_PATH)
data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


class Excel(RestClient):

    def __init__(self, api_root_url, **kwargs):
        super(Excel, self).__init__(api_root_url, **kwargs)

    def upload(self, **kwargs):
        '''
        文件上传（excel和csv）
        '''
        return self.post("/api/excel/upload", **kwargs)

    def preview(self,**kwargs):
        '''
        文件预览
        '''
        return self.post("/api/excel/preview", **kwargs)

    def parser(self,**kwargs):
        '''
        文件解析
        '''
        return self.post("/api/excel/parser", **kwargs)

    def title_check(self,**kwargs):
        '''
        检查工作表名称
        '''
        return self.post("/api/excel/title_check", **kwargs)

    def create(self, **kwargs):
        '''
        创建工作表
        '''
        return self.post("/api/excel/create", **kwargs)


    def list(self, **kwargs):
        '''
        获取工作表的excel列表
        '''
        return self.post("/api/excel/list", **kwargs)


excel = Excel(api_root_url)
